//
//  NavigationBarStyle.swift
//  Lease_IOS
//
//  Created by Mr.wang on 2018/12/20.
//  Copyright © 2018 Mr.wang. All rights reserved.
//

import UIKit

enum NavigationBarStyle {
    case normal
    case baseColor
    case clearColor
}

enum BackButtonStyle {
    case none
    case normal
}

extension UINavigationController {
    
    func setNavigationBarStyle(_ style: NavigationBarStyle) {
        var tintColor = UIColor.black
        var isTranslucent = false
        var backgroundImage = UIImage()
        
        switch style {
        case .normal:
            backgroundImage = UIImage.imageWithColor(.white)
        case .clearColor:
            tintColor = UIColor.white
            isTranslucent = true
        case .baseColor:
            tintColor = UIColor.white
            backgroundImage = UIImage.imageWithColor(APPConfig.baseColor)
        }
        
        navigationBar.tintColor = tintColor
        navigationBar.isTranslucent = isTranslucent
        
        var titleTextAttributes = self.navigationBar.titleTextAttributes ?? [:]
        titleTextAttributes[.foregroundColor] = tintColor
        navigationBar.setBackgroundImage(backgroundImage)
        navigationBar.setTitleTextAttributes(titleTextAttributes)
        navigationBar.setShadowImage(UIImage.clear)
    }
    
}
